package com.nts.visionworks.business.contents.domain;

// Generated 2013. 6. 23 ���� 6:33:40 by Hibernate Tools 4.0.0

import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Min;

import com.nts.visionworks.core.validation.EntityIdNotNull;

/**
 * ContentsElement generated by hbm2java
 */
@Entity
@Table(name = "contents_element", catalog = "visionworks")
public class ContentsElement implements java.io.Serializable
{

	private Integer contentsElementId;
	private ContentsTemplateElement contentsTemplateElement;
	private Contents contents;
	private int elementOrder;
	private Set<ContentsMedia> contentsMedias = new HashSet<ContentsMedia>(0);

	public ContentsElement()
	{
	}

	public ContentsElement(ContentsTemplateElement contentsTemplateElement,
			Contents contents, int elementOrder)
	{
		this.contentsTemplateElement = contentsTemplateElement;
		this.contents = contents;
		this.elementOrder = elementOrder;
	}

	public ContentsElement(ContentsTemplateElement contentsTemplateElement,
			Contents contents, int elementOrder,
			Set<ContentsMedia> contentsMedias)
	{
		this.contentsTemplateElement = contentsTemplateElement;
		this.contents = contents;
		this.elementOrder = elementOrder;
		this.contentsMedias = contentsMedias;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "ContentsElementId", unique = true, nullable = false)
	public Integer getContentsElementId()
	{
		return this.contentsElementId;
	}

	public void setContentsElementId(Integer contentsElementId)
	{
		this.contentsElementId = contentsElementId;
	}

	@EntityIdNotNull(message = "validation.contents.contentsElement.contentsTemplateElement.notNull")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TemplateElementId", nullable = false)
	public ContentsTemplateElement getContentsTemplateElement()
	{
		return this.contentsTemplateElement;
	}

	public void setContentsTemplateElement(
			ContentsTemplateElement contentsTemplateElement)
	{
		this.contentsTemplateElement = contentsTemplateElement;
	}

	@EntityIdNotNull(message = "validation.contents.contentsElement.contents.notNull")
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ContentsId", nullable = false)
	public Contents getContents()
	{
		return this.contents;
	}

	public void setContents(Contents contents)
	{
		this.contents = contents;
	}

	@Min(message = "validation.contents.contentsElement.elementOrder.min", value = 1)
	@Column(name = "ElementOrder", nullable = false)
	public int getElementOrder()
	{
		return this.elementOrder;
	}

	public void setElementOrder(int elementOrder)
	{
		this.elementOrder = elementOrder;
	}

	@ManyToMany(fetch = FetchType.LAZY, mappedBy = "contentsElements")
	public Set<ContentsMedia> getContentsMedias()
	{
		return this.contentsMedias;
	}

	public void setContentsMedias(Set<ContentsMedia> contentsMedias)
	{
		this.contentsMedias = contentsMedias;
	}

}
